package yz.cp.back.common.integration;

import cn.hutool.core.util.ArrayUtil;
import lombok.Data;

import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

@Data
public class IntegrationAuthentication {
    private String authType;
    private String produce;
    private String credentials;
    private String username;
    private Map<String, String[]> authParameters;
    private Object body;

    public String getAuthParameter(String parameter){
        String[] values = this.authParameters.get(parameter);
        if(values != null && values.length > 0){
            return values[0];
        }
        return null;
    }

    public Map<String,String> getStringMap(){
        Iterator i$ = Collections.unmodifiableMap(authParameters).entrySet().iterator();
        Map<String, String> params = new HashMap();

        while(i$.hasNext()) {
            Map.Entry<String, String[]> entry = (Map.Entry)i$.next();
            params.put(entry.getKey(), ArrayUtil.join((Object[])entry.getValue(), ","));
        }
        return params;
    }
}
